package com.sunhao.application;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity3 extends AppCompatActivity{

    @Override
    protected void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main3);

         EditText phone =findViewById(R.id.phone);
         EditText password =findViewById(R.id.password);
        password.setOnFocusChangeListener(new View.OnFocusChangeListener() {
             @Override
             public void onFocusChange(View v, boolean hasFocus) {
                 if(hasFocus){
                     if(TextUtils.isEmpty(phone.getText())||phone.getText().length()<11){
                         //获取焦点
                         phone.requestFocus();
                         //弹出提示
                       Toast.makeText(MainActivity3.this, "请输入11位手机密码", Toast.LENGTH_SHORT).show();
                     }
                 }
             }
         });

    }


}